package com.zcs.app.lucky.ui

import android.Manifest
import android.annotation.SuppressLint
import android.view.View
import cn.sxw.android.base.kt.BaseViewModel
import com.zcs.app.lucky.base.BaseLuckyActivity
import com.zcs.app.lucky.databinding.ActivityBlankBinding

@SuppressLint("RestrictedApi")
class BlankActivity : BaseLuckyActivity<ActivityBlankBinding, BaseViewModel>() {
    // 懒加载机制
    override fun onReady() {
        binding.toolbar.tvToolbarTitle.text = "Title Here"
        binding.loadingLayout.visibility = View.VISIBLE
        binding.toolbar.tvToolbarRight.text = "菜单"
    }

    @SuppressLint("CheckResult")
    override fun onInit() {
        rxPermissions.request(
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
        ).subscribe {
            if (it) {
                initView()
                initObserve()
                initData()
            } else {
                // 授权失败
                onNeverAsk("文件存储", withExit = true, true)
            }
        }
    }

    override fun initObserve() {
    }

    override fun initData() {
        // hide loading last
        hideLoading()
    }

    override fun initView() {
    }

    override fun hideLoading() {
        super.hideLoading()
        binding.loadingLayout.visibility = View.GONE
    }

    override fun addOnClickListener() {
        binding.toolbar.ivToolbarBack.setOnClickListener { onBackPressed() }
    }
}